home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / move16v2.lha / Move16.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-03  |  4.7 KB  |  196 lines

  1. #include <proto/exec.h>
  2. #include <exec/execbase.h>
  3. #include <exec/memory.h>
  4. #include <proto/dos.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #define MEMSIZE (1024000L)
  8.  
  9. void __regargs MoveMem(ULONG *,ULONG *,ULONG);
  10. void __regargs MoveMem16(ULONG *,ULONG *,ULONG);
  11. void main(void);
  12.  struct   tt {
  13.       long  days;
  14.       long  minutes;
  15.       long  ticks;
  16.    }  tt,tt2;
  17.  
  18.  
  19. void main()
  20. {
  21.  unsigned long cpu68040;
  22.  register unsigned int i;
  23.  ULONG *src1,*src2;
  24.  ULONG *org1,*org2,*tptr1,*tptr2;
  25.  ULONG tlong;
  26.  double q,q2;
  27.  double q3,q4;
  28.  struct ExecBase **execbaseptr=(struct ExecBase **)4;
  29.  struct ExecBase *execbase;
  30.  
  31.  execbase = *execbaseptr;
  32.  cpu68040 = execbase->AttnFlags;
  33.  if (cpu68040 & AFF_68040)
  34.   cpu68040 = 0xffL;
  35.  else
  36.   cpu68040 = 0L;
  37.  if (!cpu68040)
  38.   {
  39.    printf("You need a 68040 system\n");
  40.    exit(0);
  41.   }
  42.  execbase = *execbaseptr;
  43.  cpu68040 = execbase->AttnFlags;
  44.  if (cpu68040 & AFF_FPU40)
  45.   cpu68040 = 0xffL;
  46.  else
  47.   cpu68040 = 0L;
  48.  if (!cpu68040)
  49.   {
  50.    printf("You need a 68040 system With a Math Chip Builtin\n");
  51.    exit(0);
  52.   }
  53.  if (!(org1 = src1 = (ULONG *)AllocMem(MEMSIZE+16,MEMF_FAST)))
  54.   {
  55.    printf("No FAST mem\n");
  56.    exit(0);
  57.   }
  58.  tlong = (ULONG)src1;
  59.  tlong &= 0xfffffff0L;
  60.  tlong += 0x10L;
  61.  src1 = (ULONG *)tlong;
  62.  if (!(org2 = src2 = (ULONG *)AllocMem(MEMSIZE+16,MEMF_FAST)))
  63.   {
  64.    FreeMem(org1,MEMSIZE+16);
  65.    printf("No Fast mem\n");
  66.    exit(0);
  67.   }
  68.  tlong = (ULONG)src2;
  69.  tlong &= 0xfffffff0L;
  70.  tlong += 0x10L;
  71.  src2 = (ULONG *)tlong;
  72.  
  73.  Forbid();
  74.  
  75.  DateStamp((struct DateStamp *)&tt);
  76.  for(i=0;i<10;i++)
  77.   MoveMem(src1,src2,(MEMSIZE/16));
  78.  DateStamp((struct DateStamp *)&tt2);
  79.  q = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)))/50.0;
  80.  q2 = ( (double)(tt2.ticks + (tt2.minutes * 60L * 50L)))/50.0;
  81.  q = q2 - q;
  82.  
  83.  DateStamp((struct DateStamp *)&tt);
  84.  for(i=0;i<10;i++)
  85.   MoveMem16(src1,src2,(MEMSIZE/16));
  86.  DateStamp((struct DateStamp *)&tt2);
  87.  q3 = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)))/50.0;
  88.  q4 = ( (double)(tt2.ticks + (tt2.minutes * 60L * 50L)))/50.0;
  89.  q3 = q4 - q3;
  90.  
  91.  Permit();
  92.  FreeMem((char *)org1,MEMSIZE+16);
  93.  FreeMem((char *)org2,MEMSIZE+16);
  94.  printf("**FAST TO FAST**\n");
  95.  printf("MoveMem   = %3.4lf secs\n",q);
  96.  printf("MoveMem16 = %3.4lf secs\n",q3);
  97.  
  98.  
  99.  if (!(org1 = src1 = (ULONG *)AllocMem(MEMSIZE+16,MEMF_FAST)))
  100.   {
  101.    printf("No FAST mem\n");
  102.    exit(0);
  103.   }
  104.  tlong = (ULONG)src1;
  105.  tlong &= 0xfffffff0L;
  106.  tlong += 0x10L;
  107.  src1 = (ULONG *)tlong;
  108.  if (!(org2 = src2 = (ULONG *)AllocMem(MEMSIZE+16,MEMF_CHIP)))
  109.   {
  110.    FreeMem(org1,MEMSIZE+16);
  111.    printf("No CHIP mem\n");
  112.    exit(0);
  113.   }
  114.  tlong = (ULONG)src2;
  115.  tlong &= 0xfffffff0L;
  116.  tlong += 0x10L;
  117.  src2 = (ULONG *)tlong;
  118.  
  119.  Forbid();
  120.  
  121.  DateStamp((struct DateStamp *)&tt);
  122.  for(i=0;i<10;i++)
  123.   MoveMem(src1,src2,(MEMSIZE/16));
  124.  DateStamp((struct DateStamp *)&tt2);
  125.  q = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)))/50.0;
  126.  q2 = ( (double)(tt2.ticks + (tt2.minutes * 60L * 50L)))/50.0;
  127.  q = q2 - q;
  128.  
  129.  DateStamp((struct DateStamp *)&tt);
  130.  for(i=0;i<10;i++)
  131.   MoveMem16(src1,src2,(MEMSIZE/16));
  132.  DateStamp((struct DateStamp *)&tt2);
  133.  q3 = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)))/50.0;
  134.  q4 = ( (double)(tt2.ticks + (tt2.minutes * 60L * 50L)))/50.0;
  135.  q3 = q4 - q3;
  136.  
  137.  Permit();
  138.  printf("**Fast to CHIP**\n");
  139.  printf("MoveMem   = %3.4lf secs\n",q);
  140.  printf("MoveMem16 = %3.4lf secs\n",q3);
  141.  
  142.  
  143.  Forbid();
  144.  
  145.  DateStamp((struct DateStamp *)&tt);
  146.  for(i=0;i<10;i++)
  147.   MoveMem(src2,src1,(MEMSIZE/16));
  148.  DateStamp((struct DateStamp *)&tt2);
  149.  q = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)))/50.0;
  150.  q2 = ( (double)(tt2.ticks + (tt2.minutes * 60L * 50L)))/50.0;
  151.  q = q2 - q;
  152.  
  153.  DateStamp((struct DateStamp *)&tt);
  154.  for(i=0;i<10;i++)
  155.   MoveMem16(src2,src1,(MEMSIZE/16));
  156.  DateStamp((struct DateStamp *)&tt2);
  157.  q3 = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)))/50.0;
  158.  q4 = ( (double)(tt2.ticks + (tt2.minutes * 60L * 50L)))/50.0;
  159.  q3 = q4 - q3;
  160.  
  161.  Permit();
  162.  printf("**CHIP to Fast**\n");
  163.  printf("MoveMem   = %3.4lf secs\n",q);
  164.  printf("MoveMem16 = %3.4lf secs\n",q3);
  165.  
  166.  Forbid();
  167.  
  168.  tptr1 = src2;
  169.  tlong = (ULONG)src2;
  170.  tlong += (MEMSIZE/2);
  171.  tptr2 = (ULONG *)tlong;
  172.  DateStamp((struct DateStamp *)&tt);
  173.  for(i=0;i<20;i++)
  174.   MoveMem(tptr1,tptr2,(MEMSIZE/32));
  175.  DateStamp((struct DateStamp *)&tt2);
  176.  q = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)))/50.0;
  177.  q2 = ( (double)(tt2.ticks + (tt2.minutes * 60L * 50L)))/50.0;
  178.  q = q2 - q;
  179.  
  180.  DateStamp((struct DateStamp *)&tt);
  181.  for(i=0;i<20;i++)
  182.   MoveMem16(tptr1,tptr2,(MEMSIZE/32));
  183.  DateStamp((struct DateStamp *)&tt2);
  184.  q3 = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)))/50.0;
  185.  q4 = ( (double)(tt2.ticks + (tt2.minutes * 60L * 50L)))/50.0;
  186.  q3 = q4 - q3;
  187.  
  188.  Permit();
  189.  printf("**CHIP to CHIP**\n");
  190.  printf("MoveMem   = %3.4lf secs\n",q);
  191.  printf("MoveMem16 = %3.4lf secs\n",q3);
  192.  
  193.  FreeMem((char *)org1,MEMSIZE+16);
  194.  FreeMem((char *)org2,MEMSIZE+16);
  195. }
  196.